import React from 'react'
import {
  Form,
  Input,
  Button, 
} from 'antd-mobile'
import { getRegApi } from '../../api/request' 
import { useNavigate } from 'react-router-dom'
function index() { 
  const nav=useNavigate()
  const onFinish=async(val)=>{ 
    console.log(val)
    const resp= await getRegApi(val)
    console.log(resp)
    alert(resp.data.data)
    nav('/login')
  } 
  return (
    <div> 
        <Form
        onFinish={onFinish}
        layout='horizontal'
        footer={
          <Button block type='submit' color='primary' size='large' >
            注册
          </Button>
        }
      > 
        <Form.Item
          name='username'
          label='用户名'
          rules={[{ required: true, message: '用户名不能为空' }]}
        >
          <Input  placeholder='请输入用户名' />
        </Form.Item>
        <Form.Item
          name='password'
          label='密码'
          rules={[{ required: true, message: '密码不能为空' }]}
        >
          <Input  placeholder='请输入密码' />
        </Form.Item>
        </Form>
    </div>
  )
}

export default index